package org.singledog.form.builder.view;

import org.singledog.form.builder.ComponentType;

import java.util.Collections;
import java.util.Map;

/**
 * @author adam
 * @date 2019/4/30
 */
public interface View {

	ComponentType viewType();

	/**
	 * view code
	 * @return
	 */
	String getViewCode();

	/**
	 * html string for display purpose
	 * @return
	 */
	String toHtml(ViewInterceptor customizer, Map<String, Object> viewData, boolean readonly);

	default String toHtml(boolean readonly) {
		return toHtml(null, Collections.emptyMap(), readonly);
	}

	default String toHtml(Map<String, Object> viewData) {
		return toHtml(null, viewData, false);
	}

	default String toHtml(ViewInterceptor interceptor, Map<String, Object> viewData) {
		return toHtml(interceptor, viewData, false);
	}

	default String toHtml() {
		return toHtml(false);
	}

}
